package com.hluck.navigationviewmodel

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.activityViewModels
import androidx.navigation.Navigation
import com.hluck.navigationviewmodel.databinding.FragmentDetailBinding


class DetailFragment : Fragment() {

    private val myViewModel by activityViewModels<MyViewModel>()
    private lateinit var mBinding: FragmentDetailBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        mBinding = DataBindingUtil.inflate(inflater,R.layout.fragment_detail, container, false)
        mBinding.myViewModel = myViewModel
        mBinding.lifecycleOwner = activity
        mBinding.btnBack.setOnClickListener {
            Navigation.findNavController(it).navigate(R.id.action_detailFragment_to_masterFragment)
        }

        return mBinding.root
    }


}